<?php

namespace App\Admin\Extensions;

use Encore\Admin\Admin;

class ClientConfig
{
    protected $id;

    public function __construct($sign)
    {
        $this->sign = $sign;
    }

    protected function script()
    {
        return <<<SCRIPT

layui.use('layer', function(){
       var layer = layui.layer;
  
       $('.client_config').click(function(){
           var sign = $(this).attr('data-sign');
           layer.open({
                type: 2,
                content: '/admin/clients/contacts/open/close?sign='+sign,
                area: ['80%', '500px']
           });
       });
});
SCRIPT;
    }

    protected function render()
    {
        Admin::script($this->script());

        return "&nbsp;<a class='btn client_config btn-xs btn-success fa grid-check-row' data-sign='{$this->sign}'>配置</a>";

    }

    public function __toString()
    {
        return $this->render();
    }
}